package anim;

import logic.PointD;
import vis.Drawable;

public class MoveObject extends Frame {

	private Drawable object = null;
	private double x, y, ox, oy;
	private boolean relative;
	
	public MoveObject(Drawable obj, double x, double y, boolean relative)
	{
		this.x = x;
		this.y = y;
		this.relative = relative;
		this.object = obj;
	}
	
	public MoveObject(Drawable obj, PointD point, boolean relative)
	{
		this.x = point.getX();
		this.y = point.getY();
		this.relative = relative;
		this.object = obj;
	}
	
	@Override
	public void doFrame() {
		ox = object.getPosX();
		oy = object.getPosY();
		
		if(relative)
			object.setPosition(ox + x, oy + y);
		else
			object.setPosition(x, y);
	}

	@Override
	public void undoFrame() {
		object.setPosition(ox, oy);
	}

}
